import { request } from '@umijs/max';

// 汇总
export async function querySummary() {
  return request('/api/summary');
}

// 分镜列表
export async function queryShotsList(params: any) {
  return request('/api/shots', {
    params
  });
}

// 删除分镜
export async function delShortItem(id: string | number) {
  return request(`/api/shots/${id}`, {
    method: 'DELETE',
  });
}

// 新增分镜
export async function addShortItem(data: any) {
  return request(`/api/shots`, {
    method: 'POST',
    data
  });
}

//加锁状态
export async function queryLockShortItem(id: any) {
  return request(`/api/shots/${id}/lock-status`);
}

//加锁
export async function lockShortItem(data: any) {
  const { id, lock_duration_minutes } = data
  return request(`/api/shots/${id}/lock?lock_duration_minutes=${lock_duration_minutes}`, {
    method: 'POST',
  });
}

//解锁
export async function delockShortItem(id: any) {
  return request(`/api/shots/${id}/lock`, {
    method: 'DELETE',
  });
}

// 编辑分镜
export async function editShortItem(params: any) {
  const { id, ...data } = params
  return request(`/api/shots/${id}`, {
    method: 'PUT',
    data
  });
}

// 获取分镜媒体资源list
export async function queryShortMediaList(id: any) {
  return request(`/api/shots/${id}/media`);
}

// 媒体投票
export async function queryShortMediaVote(id: any) {
  return request(`/api/shots/${id}/vote`);
}

// 获取评论列表
export async function queryShortComments(id: any) {
  return request(`/api/comments/shot/${id}`);
}

// 获取评论列表
export async function createShortComments(data: any) {
  return request(`/api/comments`, {
    method: 'POST',
    data
  });
}

// 新增关键帧列表
export async function addShortKeyframes(data: any) {
  return request(`/api/keyframes`, {
    method: 'POST',
    data
  });
}

// 获取关键帧列表
export async function queryShortKeyframes(id: any) {
  return request(`/api/keyframes?shot_id=${id}`);
}

// 编辑关键帧列表
export async function editShortKeyframes(data: any) {
  return request(`/api/keyframes/${data?.keyframe_id}`, {
    method: 'PUT',
    data
  });
}

// 删除关键帧列表
export async function delShortKeyframes(keyframe_id: any) {
  return request(`/api/keyframes/${keyframe_id}`, {
    method: 'DELETE',
  });
}

// 关键帧上传视频
export async function queryShortKeyframesList(keyframe_id: any) {
  return request(`/api/keyframes/${keyframe_id}/media`);
}